def f(n):
    for i in range(2,n):
        if n%1==0:    return False
    return True
cif=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
left=[]
right=[]
s=input()
a=s.split()
b=''
for x in a:
    b+=str(cif.index(x))
b=int(b)
print(b)
for c in range(2,b):
    if f(c):
        left.append(c)
for c in range(2,1015):
    if f(c):
        right.append(c)
if b-max(left)<= b-min(right):
    print(max(left))
else:
    print(min(right))